import sys
commands = []
result = []
pos = 0 #游标位置
for command in sys.stdin:
    
    
    command = command.split()
    if command[0] == 'insert':
        
        if pos > 0:
            insert_str = []
            for code in command[1]:
                insert_str.append(code)
            
            result = result[:pos] + insert_str + result[pos:]
            pos += len(insert_str)
        else:
            for code in command[1]:
                result.append(code)
            pos = len(result)
                
            
    elif command[0] == 'move':
        step = int(command[1])
        if step > 0:
            if pos + step > len(result):
                continue
            else:
                pos += step
        elif step < 0:
            if pos + step < 0:
                continue
            else:
                pos += step
    elif command[0] == 'delete':
        number = int(command[1])
        if number < 0 or number > len(result):
            continue
        result = result[:pos-number] + result[pos:]
        pos -= number
        
    elif command[0] == 'copy':
        result = result[:pos] + result[:pos] + result[pos:]
    else:
        result = result[:pos] + ['|'] + result[pos:]
        break
print(''.join(result))
        
    

            
        